package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author 李明洋
 * @date 2025/3/26 9:06
 * @version: 1.0
 */
public class JDBCDemo9 {
    public static void main(String[] args) {
        try( Connection connection = DBUti1.getconnection();) {
            connection.setAutoCommit(false);
            String sql = "update user set password=?,nickname=?,age=? where id=?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"1998");
            ps.setString(2,"小李李");
            ps.setInt(3,14);
            ps.setInt(4,5);
            int num = ps.executeUpdate();
            System.out.println(num>0?"成功":"失败");

            connection.commit();

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
